
/************************ (C) COPYRIGHT 2015 FT *******************************
* File Name          : 
* Author             : Application Team  Tom.wang 
* Version            : V2.0.0
* Date               : 06/15/2015
* Description        : 
********************************************************************************
/*******************************************************************************
* All Rights Reserved
*******************************************************************************/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __FLASH_H
#define __FLASH_H
#define     __I     volatile const    /*!< defines 'read only' permissions      */
#define     __O     volatile          /*!< defines 'write only' permissions     */
#define     __IO    volatile          /*!< defines 'read / write' permissions   */

#define   START_WriteADDRESS  0x3E00             //写入首地址
#define   Write_Lenght        4                  //写入字节长度
#define   Verify_Bit          Write_Lenght -1    //Data数值最后位为校验位
#define   Verify_Ture         0xFF               //校验正确数值
#define   Verify_Error        0x55               //校验错误数值

typedef struct
{
	uint16 WriteAddress;     // 写入地址 
	uint8  WriteValue[8];    // Flash 写入数组
	uint16 ReadAddress;      // 读取地址
	uint8  ReadValue[8];     // ROM 读出值
	uint8  FlagFlashWrite;   // 写标志位
	uint8  Flag_FlashErase;  // Flash擦除标志位
}ROM_TypeDef;

extern ROM_TypeDef xdata  FlashData;  
extern uint8  ReadFlashValue(uint16 ReadAddress);
extern uint8  Flash_WriteValue(uint16 WriteAddress ,uint8 Length,uint8 * str);
extern uint16 GetWrite_Black_Addr(unsigned short FlashAddress, uint8 Write_Length);
extern void   ReadFromFlash(unsigned short BlockStartAddr, uint8 Length, uint8 * str);
extern void Flash_Erase(void);
extern void   Save_KeyValue(void);
#endif